package com.recommendation.action;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.quartz.SchedulerException;

import com.recommendation.service.RecommendEngine;

@Results({
	@Result(name="success", type="httpheader"),
	@Result(name="error", type="httpheader")
})
public class StopAction extends ActionBase{

	public String execute()
	{
		_log.info("stopping...");
		long userId = getUserId();
		RecommendEngine engine = new RecommendEngine(userId);
		try {
			//engine.pause();
			engine.shutDown();
			_log.info("stopped...");
		} catch (SchedulerException e) {
			error(e);
			return ERROR;
		}
		return SUCCESS;
	}
}
